package basic;

public class MethodDemo5 {
    public boolean contains(int[] arr, int element){
        boolean result = false;
        for (int value : arr){
            if (value == element){
                result = true;
                break;
            }
        }
        return result;
    }

    public static void main(String[] args) {
        // 实例化MethodDemo5
        MethodDemo5 methodDemo5 = new MethodDemo5();
        int[] intArray = {1,2,3,4,5};
        int element = 6;
        // 调用contains方法，并接收返回结果
        boolean contains = methodDemo5.contains(intArray,element);
        if(contains){
            System.out.println("数组intArray中包含" + element);
        }else {
            System.out.println("数组intArray中不包含" + element);
        }
    }
}
